package com.mindskip.xzs.controller.admin;

import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.service.NewExamPaperAnswerService;
import com.mindskip.xzs.viewmodel.admin.exam.FinishPagerRes;
import com.mindskip.xzs.viewmodel.admin.exam.PageFinishPagerReq;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

@RestController("NewExamPaperAnswerController")
@RequestMapping(value = "/api/admin/newExamPaperAnswer")
public class NewExamPaperAnswerController {

    @Resource
    private NewExamPaperAnswerService newExamPaperAnswerService;

    @RequestMapping(value = "/page/v1", method = RequestMethod.POST)
    public RestResponse<PageInfo<FinishPagerRes>> pageJudgeListV1(@RequestBody @Valid PageFinishPagerReq req) {
        return RestResponse.ok(newExamPaperAnswerService.adminPage(req));
    }

    @RequestMapping(value = "/export/excel", method = RequestMethod.POST)
    public void exportExcel(@RequestBody @Valid PageFinishPagerReq req, HttpServletResponse response) {
        newExamPaperAnswerService.exportExcel(req,response);
    }

    @GetMapping("/del")
    public RestResponse<Boolean> delPaperAnswer(@RequestParam("id") Long id) {
        return RestResponse.ok(newExamPaperAnswerService.removeById(id));
    }
}
